--- zrob plik konfiguracyjny i zaladuj go uzywajac dofile()
chestTable = {
	[1] = {chest1 = 5948, chest2 = 2301, chest3 = 2365, count2 = 5}, --- red dragon leather, fire field rune
	[2] = {chest1 = 2156, chest2 = 2795, count2 = 5, chest3 = 2365}, --- red gem, fire mushrooms, v rod [nie istnieje]
	[3] = {chest1 = 2363, chest2 = 2546, count2 = 5, chest3 = 2200}, -- blood orb, burst arrow, protection amulet
	[4] = {chest1 = 2365, chest2 = 2201, chest3 = 5882} --- backpack of holding, dragon necklace, red dragon scale
}

chestTable[5] = chestTable[1]
chestTable[6] = chestTable[2]
chestTable[7] = chestTable[3]
chestTable[8] = chestTable[4]

enter_pos = {x = 272, y = 134, z = 9}
storage = 1111

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerStorageValue(cid, storage) == 1 then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It's empty.")
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF, cid)
		doTeleportThing(cid, enter_pos)
		return true
	end

	local TABLE = chestTable[getPlayerVocation(cid)]

	local uidRewardTable = {
		[1113] = {reward = TABLE.chest1, count = TABLE.count1},
		[1114] = {reward = TABLE.chest2, count = TABLE.count2},
		[1115] = {reward = TABLE.chest3, count = TABLE.count3}
	}

	local infoTableReward = uidRewardTable[itemEx.uid]

	if infoTableReward.count == nil then
		infoTableReward.count = 1
	end

	if getPlayerFreeCap(cid) < getItemWeightById(infoTableReward.reward, infoTableReward.count) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is too heavy.")
		return true
	end

	if doPlayerAddItem(cid, infoTableReward.reward, infoTableReward.count, false) == false then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You don't have enought room.")
		return true
	else
		tmp = getItemDescriptions(infoTableReward.reward)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found "..tmp.article.." "..tmp.name..".\nYou got new outfit.")
		
		if getPlayerSex(cid) == 0 then --- female / 0
			doPlayerAddOutfit(cid,149, 3)
		else --- male / 1
			doPlayerAddOutfit(cid,145, 3)
		end
	end
	
	doTeleportThing(cid, enter_pos)
	setPlayerStorageValue(cid, storage, 1)
	return true
end